package com.sinodata.bsm.inmp.service;

import org.apache.log4j.Logger;

import com.sinodata.bsm.inmp.cache.AttributeCache;
import com.sinodata.bsm.inmp.cache.CacheFactory;
import com.sinodata.bsm.inmp.cache.PropertyCache;
import com.sinodata.bsm.inmp.cache.ResAttrValCache;
import com.sinodata.bsm.inmp.cache.ResCache;
import com.sinodata.bsm.inmp.cache.ResRelationCache;
import com.sinodata.bsm.common.vo.Attribute;
import com.sinodata.bsm.common.vo.Property;
import com.sinodata.bsm.common.vo.Res;

public class PropertyService {
    private static Logger logger = Logger.getLogger(PropertyService.class);

    public PropertyService() {

    }

    private ResCache resCache = (ResCache) CacheFactory.getCache(ResCache.class);

    private PropertyCache propertyCache = (PropertyCache) CacheFactory.getCache(PropertyCache.class);
    private AttributeCache attributeCache = (AttributeCache) CacheFactory.getCache(AttributeCache.class);

    public void addResProperty(Property prop) {
        if (prop.getResId() != null) {
            Res res = resCache.get(prop.getResId().longValue());
            if (res == null)
                return;
            propertyCache.put(prop.getId(), prop);
        }
    }

    public void addResAttribute(Attribute attribute) {
        if (attribute.getResId() != null) {
            Res res = resCache.get(attribute.getResId().longValue());
            if (res == null)
                return;
            attributeCache.put(attribute.getId(), attribute);
        }
    }
}
